package com.api.gbhg.luoao.utils;

import cn.hutool.core.util.StrUtil;
import com.api.gbhg.liwenjun.GBHGConstant;
import com.api.gbhg.liwenjun.VersionFlowUtil;
import com.api.gbhg.zengping.common.CommonDao;
import com.api.gbhg.zengping.dao.PropertyManagementCostDao;
import com.google.common.base.Joiner;
import com.mysql.cj.x.protobuf.MysqlxDatatypes;
import emo.macro.ob.OB;
import org.jcp.xml.dsig.internal.MacOutputStream;
import weaver.conn.RecordSet;

import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.*;

public class CollectUtils {

    /**
     * 获取 申报单位 流程类型 总类型记录数
     *
     *
     * @return
     */
    public static RecordSet getUnitData(String requestId) {
        RecordSet rs = new RecordSet();
        rs.executeQuery("select ver.lcbj,ver.sbdw,count(ver.sbdw)jl from uf_jingfei_version ver, uf_dwsxpz dw where \n" +
                "ver.sbdw = dw.xzxtdw and dw.sfwdlhsdw = 1 and ver.lcztz <> 3 and ver.lcjlsqjlid in(" + requestId + ")" +
                " group by ver.sbdw,ver.lcbj");
        return rs;
    }

    //获取预算来源明细表
    public static List<String> getDetail(String lx, String fromName) {
        List<String> list = new ArrayList<>();
        String lclx = lx;
        switch (lclx) {
            case "02":
                list.add(fromName + "_dt5");
                list.add(fromName + "_dt6");
                break;
            case "05":
                list.add(fromName + "_dt4");
                list.add(fromName + "_dt5");
                break;
            default:
                list.add(fromName + "_dt3");
                list.add(fromName + "_dt4");
        }
        return list;
    }

    //获取主表名
    public static String getfromName(String requset) {
        RecordSet recordSet = new RecordSet();
        recordSet.executeQuery("select workflowid  from workflow_requestbase where requestid = " + requset);
        recordSet.next();
        String workflowid = VersionFlowUtil.getFlowTableName(recordSet.getStringNoTrim("workflowid"));
        return workflowid;
    }

    //查询根据流程查询预算来源是否有
    public static Map<String, Object> getysly(String lx, String[] map) {

        Map<String, Object> mapdata = new HashMap<>();
        List<String> list = new ArrayList<>();

        for (String maps : map) {

            //获取表名
            String fromName = getfromName(maps);
            //获取明细表名
            List<String> detail = getDetail(lx, fromName);
            //是否存在预算来源
            boolean b = getsf(fromName, detail, maps);

            if (b) {
                list.add(maps);
            } else {
                mapdata.put("requestId", maps);
                return mapdata;
            }
        }

        mapdata.put("xms", list.size());
        mapdata.put("hzxmjh", Joiner.on(",").join((Iterable<?>) list));
        return mapdata;

    }

    //查询没有预算来源的数据
    public static Map<String, Object> getdateSource(String requestId) {
        Map<String, Object> map = new HashMap<>();
        RecordSet rs = new RecordSet();
        rs.executeQuery("select xmmin from uf_jingfei_version  where lcjlsqjlid = " + requestId);
        rs.next();
        map.put("xmmin", rs.getStringNoTrim("xmmin"));
        map.put("requestId", requestId);
        map.put("result", "unfilled");
        return map;

    }


    //查询预算来源
    public static boolean getsf(String fromname, List<String> list, String requestid) {
        RecordSet rs = new RecordSet();
        for (String detail : list) {
            rs.executeQuery("select dt.ysly from " + fromname + " main," +
                    "" + detail + "  dt where main.id  =  dt.mainid and main.requestId=" + requestid);
            if (rs.next() == true) {
                return true;
            }
        }
        return false;

    }

    /**
     * 根据 申报单位获取 流程标记id
     *
     * @param sbdw
     * @param lcbj
     * @return
     */
    public static String getLabelID(String sbdw, String lcbj) {
        RecordSet rs = new RecordSet();
        rs.executeQuery("select lcjlsqjlid from uf_jingfei_version " +
                "where sbdw = " + sbdw + " and lcztz <>3 and lcbj = " + lcbj);
        List<String> list = new ArrayList<>();
        while (rs.next()) {
            list.add(rs.getStringNoTrim("lcjlsqjlid"));
        }
        return Joiner.on(",").join((Iterable<?>) list);
    }


    /**
     * 根据 流程标记id获取 总金额
     *
     * @param lcjlsqjlid
     * @return
     */
    public static RecordSet getLumpSum(String lcjlsqjlid) {
        RecordSet rs = new RecordSet();
        rs.executeQuery("select SUM(yszje)yszje from uf_jingfei_version where lcjlsqjlid in(" + lcjlsqjlid + ")");
        return rs;
    }


    /**
     * 合并数据 并且 插入至汇总表
     *
     * @param maps
     * @return
     */
    public static Map<String, Object> PoolData(String[] maps) {
        Map<String, Object> result = new HashMap<>();

        if (maps.length > 0) {
            List<String> list = new ArrayList<>();
            for (String map : maps) {
                list.add(map);
            }
            String requestId = Joiner.on(",").join((Iterable<?>) list);

            RecordSet unitData = getUnitData(requestId);
            unitData.next();
            //判断是否有 预算来源以及是否到达了指定节点
            Map<String, Object> mapdata = getysly(unitData.getStringNoTrim("lcbj"), maps);
            if (!mapdata.containsKey("requestId")) {
                mapdata.put("dw", unitData.getStringNoTrim("sbdw"));//所属单位
                mapdata.put("lx", unitData.getStringNoTrim("lcbj"));//类型

                //是否还有数据
                if (StrUtil.isNotEmpty(mapdata.getOrDefault("hzxmjh", "").toString())) {
                    String hzxmjh = mapdata.getOrDefault("hzxmjh", "").toString();
                    RecordSet lumpSum = getLumpSum(hzxmjh);
                    lumpSum.next();
                    String hjwy = lumpSum.getStringNoTrim("yszje");
                    if (hjwy.isEmpty()) {
                        hjwy = "0.00";
                    }

                    mapdata.put("hzje", hjwy);//汇总金额
                    mapdata.put("shzt", "0");//审核状态

                    String b = JudgmentType(mapdata);
                    result.put("result", b);
                    return result;
                } else {

                    result.put("result", "failure");
                    return result;
                }

            }

            return getdateSource(mapdata.getOrDefault("requestId", "").toString());

        }
        result.put("result", "failure");
        return result;

    }




    /**
     * 判断是否是同一批类型
     */
    public static String JudgmentType(Map<String, Object> map) {
//        RecordSet rs = new RecordSet();
//        SimpleDateFormat sdf = new SimpleDateFormat("yyyy");
//        Date date = new Date();
//        String format = sdf.format(date);
//        rs.executeQuery("select *  from uf_hzsbxm where " +
//                "dw = " + map.getOrDefault("dw", "").toString() + "and lx = " +
//                "" + map.getOrDefault("lx", "").toString() + "and shzt in(0,2,3) and nd = "+format);
//
////        RecordSet set = new RecordSet();
////        rs.executeQuery("select *  from uf_hzsbxm where " +
////                "dw = " + map.getOrDefault("dw", "").toString() + "and lx = " +
////                "" + map.getOrDefault("lx", "").toString() + "and shzt = 0 and nd = "+format);
//
//        //判断是否存在
//        if (rs.next() ) {
//
//           //更新数据
//         return onceagain(rs.getStringNoTrim("id"), map);
//
//        }else {
        //没有数据插入数据
        return Inserthzsbxm(map);

    }


    //批更新汇总表
    public static String onceagain(String id, Map<String, Object> map) {
        RecordSet recordSet = new RecordSet();
        boolean b = recordSet.executeUpdate("UPDATE uf_hzsbxm\n" +
                        "  SET  xms = ?, hzxmjh = ?,hzje =?,shzt = 0,spyj = '',hzhpje = 0.00 WHERE id = ?",
                map.getOrDefault("xms", "").toString(),
                map.getOrDefault("hzxmjh", "").toString(),
                map.getOrDefault("hzje", "").toString(),
                id);
        if (b) {
            return "success";
        }
        return "failure";
    }


    /**
     * 插入汇总表
     *
     * @param map
     * @return
     */
    public static String Inserthzsbxm(Map<String, Object> map) {
        RecordSet rs = new RecordSet();
        Date now = new Date();
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//可以方便地修改日期格式
        String hehe = dateFormat.format(now);

        boolean b = rs.executeUpdate("INSERT INTO uf_hzsbxm(dw,hzxmjh,lx,hzje,xms,shzt,hzhpje,nd)VALUES(?,?,?,?,?,?,?,?)",
                map.getOrDefault("dw", "").toString(),
                map.getOrDefault("hzxmjh", "").toString(),
                map.getOrDefault("lx", "").toString(),
                map.getOrDefault("hzje", "").toString(),
                map.getOrDefault("xms", "").toString(),
                map.getOrDefault("shzt", "").toString(),
                "0.00",
                hehe
        );
        if (b) {
            //插入成功
            boolean insertfhks = insertfhks(map.getOrDefault("hzxmjh", "").toString());
            if (insertfhks){
                return "success";
            }
        }
        //插入失败
        return "failure";
    }


    /**
     * 汇总上报核批列表
     *
     * @param map
     * @return
     */
    public static RecordSet getCollectLsit(Map<String, Object> map) {
        int pageNum = Integer.parseInt(map.get("pageNum").toString());
        int pageSize = Integer.parseInt(map.get("pageSize").toString());
        pageNum = (pageNum - 1) * pageSize;

        StringBuffer sb = new StringBuffer();
        sb.append("select xm.id, hrm.subcompanyname,xm.lx,xm.hzje,xm.xms, " +
                "xm.hzhpje,xm.shzt,xm.spyj,xm.hzxmjh from  " +
                "uf_hzsbxm xm join HrmSubCompany  hrm on xm.dw = hrm.id ");

        //判断单位和类型是否为空
        if (StrUtil.isNotEmpty(map.getOrDefault("dw","").toString())
                && StrUtil.isNotEmpty(map.getOrDefault("lx","").toString())){

            sb.append("  where hrm.id ="+map.getOrDefault("dw","").toString()+"  " +
                    "and xm.lx="+map.getOrDefault("lx","").toString());

        }else  if (StrUtil.isNotEmpty(map.getOrDefault("dw","").toString())){
            sb.append("  where hrm.id ="+map.getOrDefault("dw","").toString()+"  ");

        }else if (StrUtil.isNotEmpty(map.getOrDefault("lx","").toString())){
            sb.append("  where xm.lx="+map.getOrDefault("lx","").toString());
        }

        sb.append("  order by xm.shzt ,xm.nd desc offset " + pageNum + " rows fetch next " + pageSize + " rows only");


        RecordSet rs = new RecordSet();
        rs.executeQuery(sb.toString());
        return rs;
    }

    //根据id 查询汇总上报项目表
    public static String getrequestId(String id) {
        RecordSet rs = new RecordSet();
        rs.executeQuery("select hzxmjh from uf_hzsbxm where id = " + id);
        rs.next();
        return rs.getStringNoTrim("hzxmjh");
    }

    //根据项目集合查询项目名已经requestId
    public static Map<String, String>[] getProcessInformation(String hzxmjh) {
        PropertyManagementCostDao rmcd = new PropertyManagementCostDao();

        RecordSet rs = new RecordSet();
        rs.executeQuery(" select fzr,yszje,lcjlsqjlid,xmmin,sbks,sbdw  from  uf_jingfei_version where requestId in(" + hzxmjh + ")");
        Map<String, String>[] map = new HashMap[rs.getArray().size()];
        int i = 0;
        while (rs.next()) {
            map[i] = new HashMap<>();
            map[i].put("requestId", rs.getStringNoTrim("lcjlsqjlid"));
            map[i].put("xmmin", rs.getStringNoTrim("xmmin"));//项目名称

            //经办人
            RecordSet userNameById = rmcd.getUserNameById(rs.getInt("fzr"));
            userNameById.next();
            String loginid = userNameById.getString("lastname");
            map[i].put("jbr", loginid);

            //预算总金额
            map[i].put("yszje", rs.getStringNoTrim("yszje"));

            // 申报单位
            RecordSet sbdw = rmcd.getSBDWById(rs.getInt("sbdw"));
            sbdw.next();
            map[i].put("dw", sbdw.getString("SUBCOMPANYNAME"));


            //部门
            RecordSet sbks = rmcd.getSBKSById(rs.getInt("sbks"));
            sbks.next();
            map[i].put("bm", sbks.getStringNoTrim("departmentmark"));
            i++;
        }
        return map;

    }


    /**
     * 汇总上报核批列表总数据
     *
     * @return
     */
    public static int getcount() {
        RecordSet rs = new RecordSet();
        rs.executeQuery("select COUNT(*)hj from uf_hzsbxm ");
        rs.next();
        return rs.getInt("hj");
    }


    /**
     * 所属类型name
     *
     * @param lx
     * @return
     */
    public static String getTypeName(String lx) {
        GBHGConstant.FlowVersionTableEnum[] values = GBHGConstant.FlowVersionTableEnum.values();
        for (int i = 0; i < values.length; i++) {
            if (values[i].getFlowType().equals(lx)) {
                String flowName = values[i].getFlowName();
                return flowName.substring(3, flowName.length() - 1);
            }
        }
        return null;
    }


    /**
     * 更新汇总上报项目表
     *
     * @param map
     * @return
     */
    public static boolean getUpdatathzsbxm(Map<String, Object> map) {
        RecordSet recordSet = new RecordSet();
        boolean b = recordSet.executeUpdate("UPDATE uf_hzsbxm\n" +
                        "  SET  hzhpje = ?,shzt = ?,spyj = ? WHERE id = ?",
                map.getOrDefault("hzhpje", ""),
                map.getOrDefault("shzt", ""),
                map.getOrDefault("spyj", ""),
                map.getOrDefault("id", ""));
        return b;
    }


    /**
     * 获取汇总项目集合
     *
     * @param map
     * @return
     */
    public static String getrequestID(Map<String, Object> map) {
        RecordSet rs = new RecordSet();
        rs.executeQuery("select hzxmjh from uf_hzsbxm where id = ?", map.get("id"));
        rs.next();
        return rs.getStringNoTrim("hzxmjh");
    }

    //审核不同意 数据存至汇总上报返回科室表
    public static boolean SaveDisagree(Map<String, Object> map) {
        Date now = new Date();
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//可以方便地修改日期格式
        String hehe = dateFormat.format(now);

        RecordSet data = getData(getrequestID(map));
        while (data.next()) {
            Map<String, String> param = new HashMap<>();
            param.put("requestId", data.getStringNoTrim("lcjlsqjlid"));//流程id
            param.put("xmmc", data.getStringNoTrim("xmmin"));//项目名称
            String hjwy = data.getStringNoTrim("yszje");
            if (hjwy.isEmpty()) {
                hjwy = "0.00";
            }
            param.put("sbdw", data.getStringNoTrim("sbdw"));//上报单位
            param.put("sbje", hjwy);//上报金额
            param.put("hzsbid", map.get("id").toString());//汇总上报项目表所属id
            param.put("lclx", data.getStringNoTrim("lcbj"));//流程类型
            param.put("sj", hehe);//时间
            boolean inserthzsbfhks = inserthzsbfhks(param);//插入至汇总上报返回科室表
            if (!inserthzsbfhks) return false;
        }
        return true;

    }

    //根据requestid在版本主表总查询
    public static RecordSet getData(String requsetid) {
        RecordSet rs = new RecordSet();
        rs.executeQuery("select lcjlsqjlid,xmmin,yszje,lcbj,sbdw from uf_jingfei_version where  lcjlsqjlid in(" + requsetid + ")");
        return rs;

    }

    //插入数据至汇总上报返回科室表
    public static boolean inserthzsbfhks(Map<String, String> maps) {
        RecordSet rs = new RecordSet();
        boolean b = rs.executeUpdate("INSERT INTO uf_hzsbfhks (requestId ,xmmc,sbje,hzsbid ,lclx,sbdw,xgzt,sj)" +
                        " VALUES(?,?,?,?,?,?,?,?)",
                maps.getOrDefault("requestId", ""),
                maps.getOrDefault("xmmc", ""),
                maps.getOrDefault("sbje", ""),
                maps.getOrDefault("hzsbid", ""),
                maps.getOrDefault("lclx", ""),
                maps.getOrDefault("sbdw", ""),
                "0",
                maps.getOrDefault("sj", "")

        );
        return b;

    }

    //根据流程类型查询汇总上报返回科室表
    public static RecordSet getSummaryReturn(Map<String, Object> maps) {
        RecordSet rs = new RecordSet();

//        String lclx = maps.getOrDefault("lclx", "").toString();
//        String dw = maps.getOrDefault("dw", "").toString();
        rs.executeQuery(" select *  from uf_hzsbfhks where  xgzt = 0 and  hzsbid ="+maps.getOrDefault("id","").toString());

        return rs;
    }

    //查询汇总上报返回科室表总数
    public static int getSummaryReturnCount(String lclx) {
        RecordSet rs = new RecordSet();
        rs.executeQuery("select COUNT(*)zj  from uf_hzsbfhks where lclx = " + lclx);
        rs.next();
        return rs.getInt("zj");
    }

    //查询预算科审批总金额 审批意见
    public static RecordSet getthzsbxmjeyj(String lclx) {
        RecordSet recordSet = new RecordSet();
        recordSet.executeQuery("select * from  uf_hzsbxm   where id =" + lclx);
        return recordSet;
    }


    //更新汇总上报返回科室表数据
    public static boolean Updatahzsbfhks(Map<String, Object>[] map) {
        RecordSet rs = new RecordSet();
        for (Map<String, Object> maps : map) {
            String a = "0.00";
            if (StrUtil.isNotEmpty(maps.getOrDefault("zpje", "").toString())) {
                a = maps.getOrDefault("zpje", "").toString();
            }
            boolean b1 = rs.executeUpdate("UPDATE uf_hzsbfhks SET zpje =" + a + " " +
                    ",bz ='" + maps.getOrDefault("bz", "") + "'" +
                    " ,xgzt = 1 " +
                    "  WHERE  id =" + maps.getOrDefault("id", ""));
            if (!b1) {
                return false;
            }
        }
        //更新流程主表核批总金额
        String getid = getid(map);
        RecordSet  recordSet = new RecordSet();
        recordSet.executeQuery("select *  from uf_hzsbfhks where  xgzt = 0 and  hzsbid ="+getid);
        if (!recordSet.next()) {
            boolean updatahzshjezt = Updatahzshjezt(getid);

            return updatahzshjezt;
        } else {
            return true;
        }
    }



    //更新汇总上报审批表
    public static boolean Updatahzshjezt(String id) {
        RecordSet rs = new RecordSet();
        boolean b = rs.executeUpdate("UPDATE uf_hzsbxm SET " +
                "shzt=2  WHERE  id =" + id);
        return b;
    }

    //查询id
    public static String getid(Map<String, Object>[] maps) {
        RecordSet rs = new RecordSet();
        rs.executeQuery("select hzsbid from uf_hzsbfhks where requestId = " + maps[0].get("requestId").toString());
        rs.next();
        return rs.getStringNoTrim("hzsbid");
    }


    //查询流程需要退回的节点
    public static Map<String,Object>[] getProcessnode(Map<String, Object>[] map) {

        //过滤

        List<String> requestId = new ArrayList<>();
        List<String> bz = new ArrayList<>();
        for (Map<String, Object> pr : map) {
//            if (StrUtil.isNotEmpty(pr.getOrDefault("zpje", "").toString())
//                    && !pr.getOrDefault("zpje", "").toString().equals("0.00")
//                    && !pr.getOrDefault("zpje", "").toString().equals(
//                    pr.getOrDefault("sbje", "").toString())) {

                requestId.add(pr.getOrDefault("requestId", "").toString());
                bz.add(pr.getOrDefault("bz", "").toString());
           // }


        }

        Map<String, Object>[] maps = new HashMap[requestId.size()];
        int i = 0;
        for (int k = 0; k < requestId.size(); k++) {
            String nodeid = getnodeid(getworkflowid(requestId.get(k)));
            maps[i] = new HashMap<>();
            maps[i].put("requestId", requestId.get(k));
            maps[i].put("nodeid", nodeid);
            maps[i].put("remark", bz.get(k));
            i++;
        }


        return maps;

    }


    //所属流程类型id
    public static String getworkflowid(String requestId) {
        RecordSet rs = new RecordSet();
        rs.executeQuery("select workflowid from workflow_requestbase where requestid=" + requestId);
        rs.next();
        return rs.getStringNoTrim("workflowid");
    }

    //查询节点id
    public static String getnodeid(String workflowid) {
        RecordSet recordSet = new RecordSet();
        recordSet.executeQuery("select MIN(nodeid)nodeid from workflow_nodelink where workflowid = " + workflowid);
        recordSet.next();
        return recordSet.getStringNoTrim("nodeid");
    }


//    //查询汇总上报的id
//    public static boolean gethzsbid(Map<String,Object>[] maps){
//        RecordSet recordSet  = new RecordSet();
//        recordSet.executeQuery("select hzsbid from uf_hzsbfhks " +
//                "where requestId = "+maps[0].getOrDefault("requestId","").toString());
//        recordSet.next();
//
//        return
//    }

    //根据当前用户查询是否为独立核算单位
    public static RecordSet getunit(Map<String, Object> map) {
        RecordSet rs = new RecordSet();
        rs.executeQuery("select * from uf_dwsxpz where xzxtdw = "
                + map.getOrDefault("dw", "").toString()
                + " and sfwdlhsdw = 1");

        return rs;
    }


    /**
     * 查看本年是否已经汇总上报
     * 如果已经汇总了 返回false 否则 true
     *
     * @param map
     * @return
     */
    public static boolean getnd(Map<String, Object> map) {
        RecordSet rs = new RecordSet();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy");
        Date date = new Date();
        String format = sdf.format(date);
        rs.executeQuery(" select * from uf_hzsbxm where dw =" + map.getOrDefault("dw", "").toString() +
                "  and lx = " + map.getOrDefault("lx", "").toString()
                + " and nd = " + format);
        if (rs.next()) {
            return false;
        } else {
            return true;
        }

    }

    /**
     * 查看科目表里面的数据状态是否为3
     *
     * @param map
     * @return
     */
    public static boolean getshzt(Map<String, Object> map) {
        RecordSet rs = new RecordSet();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy");
        Date date = new Date();
        String format = sdf.format(date);
        rs.executeQuery(" select * from uf_hzsbxm where dw =" + map.getOrDefault("dw", "").toString() + "" +
                "  and lx = " + map.getOrDefault("lx", "")
                + " and nd = " + format + " and shzt = 3");
        if (rs.next()) {
            return true;
        } else {
            return false;
        }
    }


    //把核批金额插入至对应类型的流程表单中
    public static boolean InsertProcess(Map<String, Object>[] map) {
        RecordSet rs = new RecordSet();
        for (Map<String, Object> maps : map) {

            //没有值的不进行更新
//            if (StrUtil.isNotEmpty(maps.getOrDefault("zpje", "").toString())
//                    && !maps.getOrDefault("zpje", "").equals("0.00")
//                    && !maps.getOrDefault("zpje", "").toString().equals(
//                    maps.getOrDefault("sbje", "").toString())) {

                String requestId = maps.getOrDefault("requestId", "").toString();
                boolean b = rs.executeUpdate("update " + getfromName(requestId) +
                        "  set cpje = " + maps.getOrDefault("zpje", "").toString() +
                        "  where requestId = " + maps.getOrDefault("requestId", "").toString()
                );
                if (!b) return false;
            //}
        }
        return true;

    }

    //插入数据至汇总返回科室表
    public static  boolean insertfhks(String hzxmjh){
        Date now = new Date();
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//可以方便地修改日期格式
        String hehe = dateFormat.format(now);

        RecordSet data = getData(hzxmjh);
        while (data.next()) {
            Map<String, String> param = new HashMap<>();
            param.put("requestId", data.getStringNoTrim("lcjlsqjlid"));//流程id
            param.put("xmmc", data.getStringNoTrim("xmmin"));//项目名称
            String hjwy = data.getStringNoTrim("yszje");
            if (hjwy.isEmpty()) {
                hjwy = "0.00";
            }
            param.put("sbdw", data.getStringNoTrim("sbdw"));//上报单位
            param.put("sbje", hjwy);//上报金额
            param.put("hzsbid", getid());//汇总上报项目表所属id
            param.put("lclx", data.getStringNoTrim("lcbj"));//流程类型
            param.put("sj", hehe);//时间
            boolean inserthzsbfhks = inserthzsbfhks(param);//插入至汇总上报返回科室表
            if (!inserthzsbfhks) return false;
        }
        return true;
    }

    //找寻汇总返回科目表id
    public static String getid(){
        RecordSet  rs = new RecordSet();
        rs.executeQuery("select MAX(id)id from uf_hzsbxm");
        rs.next();
        return rs.getStringNoTrim("id");
    }


}
